// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "EnumAll.h"
#include "PetBaseCharacter.h"
#include "Blueprint/UserWidget.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/Character.h"
#include "GameFramework/SpringArmComponent.h"
#include "AbilitySystemInterface.h"
#include "Ability/BaseGameplayAbility.h"
#include "PlayCharacter.generated.h"

UCLASS()
class SSHOOT_API APlayCharacter : public ACharacter, public IAbilitySystemInterface
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	APlayCharacter();
	
	// 摄像机手臂
	UPROPERTY(VisibleAnywhere,BlueprintReadOnly)
	USpringArmComponent* SpringArmComponent;


	/// 摄像机
	UPROPERTY(VisibleAnywhere,BlueprintReadOnly)
	UCameraComponent* CameraComponent;

	// 是否蹲
	UPROPERTY(VisibleAnywhere,BlueprintReadOnly)
	bool isCrouch = false;

	UPROPERTY(VisibleAnywhere,BlueprintReadWrite)
	AActor* SelectActor;

	UPROPERTY(VisibleAnywhere,BlueprintReadWrite)
	TObjectPtr<APetBaseCharacter> fightPet;

	UPROPERTY(VisibleAnywhere,BlueprintReadWrite)
	FVector PetMoveLocation = FVector::Zero();

	UPROPERTY(VisibleAnywhere,BlueprintReadWrite,Category="ability")
	class UAbilitySystemComponent* AbilitySystemComponent;
	
protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// 人物前后移动
	void MoveForward(float Value);
	
	// 人物左右移动
	void MoveRight(float Value);
	
	// 蹲
	void PlayCrouch();

	void GenerateWeapons();
	
public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

	/**
	 * @brief 开启冷却时间
	 * @param UW 
	 */
	UFUNCTION(BlueprintImplementableEvent,BlueprintCallable)
	void EnableColldown(const UUserWidget* UW);

	/**
	 * @brief 获取冷冷却时间
	 * @param UW 
	 */
	UFUNCTION(BlueprintImplementableEvent,BlueprintCallable)
	void GetColldown(const UUserWidget* UW,float &colldown);

private:
	UFUNCTION(BlueprintCallable)
	void UseSkill(FSkillInfoStruct SkillInfo,UUserWidget* UW);


	void FeeDingUse(FSkillInfoStruct SkillInfo,UUserWidget* UW);
    
    // 召唤宠物
    void CallPet(FSkillInfoStruct SkillInfo,UUserWidget* UW);

	void SetPetMoveLocation();
public:
	virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
	/**
	 * @brief 添加技能
	 */
	void AquireAbility(TSubclassOf<UBaseGameplayAbility> Ability);

	void BanYueZhan();
};


